package taskhandler

import (
	"encoding/xml"
)

type Updates struct {
	XMLName xml.Name `xml:"updates,omitempty"`
	Updatex []Update `xml:"update,omitempty"`
}

type Update struct {
	XMLName     xml.Name    `xml:"update,omitempty"`
	From        string      `xml:"from,attr"`
	Type        string      `xml:"type,attr"`
	Status      string      `xml:"status,attr"`
	Id          string      `xml:"id"`
	Title       string      `xml:"title"`
	Severity    string      `xml:"severity"`
	Release     string      `xml:"release"`
	Issued      *Issued     `xml:"issued,omitempty"`
	References  *References `xml:"references,omitempty"`
	Description string      `xml:"description"`
	Pkglist     *Pkglist    `xml:"pkglist,omitempty"`
}

type Issued struct {
	XMLName xml.Name `xml:"issued,omitempty"`
	Date    string   `xml:"date,attr"`
}

type References struct {
	XMLName   xml.Name    `xml:"references,omitempty"`
	Reference []Reference `xml:"reference,omitempty"`
}

type Reference struct {
	XMLName xml.Name `xml:"reference,omitempty"`
	Href    string   `xml:"href,attr"`
	Id      string   `xml:"id,attr"`
	Title   string   `xml:"title,attr"`
	Type    string   `xml:"type,attr"`
}

type Pkglist struct {
	XMLName    xml.Name    `xml:"pkglist,omitempty"`
	Collection *Collection `xml:"collection,omitempty"`
}

type Collection struct {
	XMLName xml.Name  `xml:"collection,omitempty"`
	Name    string    `xml:"name"`
	Package []Package `xml:"package,omitempty"`
}

type Package struct {
	XMLName  xml.Name `xml:"package,omitempty"`
	Arch     string   `xml:"arch,attr"`
	Name     string   `xml:"name,attr"`
	Release  string   `xml:"release,attr"`
	Version  string   `xml:"version,attr"`
	Filename string   `xml:"filename"`
}

// Intermediate information
type SecurityNoticeXml struct {
	CveNum         string
	Title          string
	Type           string
	ReferenceLink  string
	Description    string
	openEulerScore float64
}

type PackRpm struct {
	PackName string
}

type CveXml struct {
	PublicDate     string
	OpenEulerSANum string
	Introduction   string
	CveLevel       string
	OwnedComponent string
	SecurityNotice map[string][]SecurityNoticeXml
	PackRpmx       map[string][]PackRpm
}
